package com.xnyzc.lhy.order.service.impl.sms;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xnyzc.lhy.common.util.ConvertUtil;
import com.xnyzc.lhy.common.util.IDUtil;
import com.xnyzc.lhy.order.entity.sms.OaSmsCodeRecord;
import com.xnyzc.lhy.order.mapper.sms.OaSmsCodeRecordMapper;
import com.xnyzc.lhy.order.service.sms.IOaSmsCodeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 短信验证码记录表 服务实现类
 * </p>
 *
 * @author liuju
 * @since 2019-07-22
 */
@Service
public class OaSmsCodeRecordServiceImpl extends ServiceImpl<OaSmsCodeRecordMapper, OaSmsCodeRecord> implements IOaSmsCodeRecordService {

    @Autowired
    IOaSmsCodeRecordService iOaSmsCodeRecordService;

    /**
     * 保存验证码
     *
     * @param phone
     * @param code
     * @param codeType
     */
    @Override
    public void saveCode(String phone, String code, Integer codeType,String userType,String tag) {
        OaSmsCodeRecord oaSmsCodeRecord = new OaSmsCodeRecord();
        Long id = IDUtil.nextId();
        Date date = new Date();
        oaSmsCodeRecord.setRecordId(id);
        oaSmsCodeRecord.setPhone(phone);
        oaSmsCodeRecord.setCodeType(codeType);
        oaSmsCodeRecord.setCode(code);
        oaSmsCodeRecord.setUserType(ConvertUtil.toInt(userType));
        oaSmsCodeRecord.setTag(tag);
        oaSmsCodeRecord.setCreateTime(date);
        oaSmsCodeRecord.setCreateUser(id);
        oaSmsCodeRecord.setUpdateUser(id);
        oaSmsCodeRecord.setUpdateTime(date);
        iOaSmsCodeRecordService.save(oaSmsCodeRecord);
    }

}
